package geocoding;

import java.text.DecimalFormat;

public class Converter {
	public int convertDouble(double d){
		String str = String.valueOf(d);
		String str2=str.replace(".","");
		while (str2.length()!=8){
		if (str2.length()>8){
			str2=removeCharAt(str2,8);
			
		}
		
		if (str2.length()<8){
			str2 = appendChar(str2);
		
		}
		}
		int i = Integer.parseInt(str2);
		return i;
	}
	
	public static String removeCharAt(String s, int pos) {
		   StringBuffer sb = new StringBuffer( s.length() - 1 );
		   sb.append( s.substring(0,pos) ).append( s.substring(pos+1) );
		   return sb.toString();
		}
	
	public static String appendChar(String s){
		StringBuffer sb = new StringBuffer(s);
		char c='0';
		sb.append(c);
		return sb.toString();

	}
	
	public double roundSixDecimals(double d) {
        DecimalFormat df = new DecimalFormat("#0.000000");
        String str = String.valueOf(d);
        String str2 = df. format(d);
        if (str.length()>9){
        return Double.valueOf(str2);
        }
        else {
        	return Double.valueOf(str); 
        }
}
}
